import request from '../../utils/request';
const consult = {
  state: {

  },

  getters: {

  },

  mutations: {

  },

  actions: {
    /**
     * 获取咨询列表
     * @payload{
     *  caseType   string 
     *  pageNum  string 
     *  province string
     *  city     string 
     *  mobileNo string
     * }
     * */ 
    GET_CONSULT_LIST({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.get('/consultation/list.htm', {
          params: payload
        }).then(res => {
          console.log('res::', res);
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    },

    /**
     * 咨询管理-新增咨询/更新咨询/删除咨询
     * @params payload{
     *  id string 咨询id，为null新增，否则更新
     *  caseType string 	案件类型
     *  type string          咨询方式， im("即时通讯"), phone("电话"), email("网站来信");
     *  title string     标题
     *  state string   状态， normal("正常"), deleted("已删除");
     *  mobileNo string
     *  province string  省id
     *  city string 市id
     *  content string 内容
     * }
     * */ 
    HANDLE_CONSULT({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/consultation/save.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    },

    /**
     * 咨询管理-详情
     * @params payload{
     *  id string 咨询id
     * }
     * */ 
    GET_CONSULT_DETAIL({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/consultation/detail.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    }

  }
}

export default consult